package com.kgc.kmall.kmallcloudmanagerweb.controller;

import com.kgc.kmall.bean.PmsBaseCatalog1;
import com.kgc.kmall.bean.PmsBaseCatalog2;
import com.kgc.kmall.bean.PmsBaseCatalog3;
import com.kgc.kmall.kmallcloudmanagerweb.service.CataFeignService;
import com.kgc.kmall.util.ResultEntity;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
public class CataController {
    @Resource
    LoadBalancerClient loadBalancerClient;
    @Resource
    CataFeignService cataFeignService;
    @RequestMapping("/getCatalog1")
    public List<PmsBaseCatalog1> getCata1(){
        System.out.println(loadBalancerClient.choose("KMALLCLOUD-MANAGER-SERVICE").getPort());
        return cataFeignService.getCata1();
    }
    @RequestMapping("/getCatalog2")
    public List<PmsBaseCatalog2> getCata2(Integer catalog1Id){
        return cataFeignService.getCata2(catalog1Id);
    }
    @RequestMapping("/getCatalog3")
    public List<PmsBaseCatalog3> getCata3( Integer catalog2Id){
        return cataFeignService.getCata3(catalog2Id);
    }
}
